<template>
	<view class="content">
		<view class="group">
			<view class="list" @click="getPayCard(1)">
				<view class="list_fl" >
					<image class="paycard" src="https://taobaoke-paimai.oss-cn-beijing.aliyuncs.com/bankpay.png" mode=""></image>
					<view class="carddsc">绑定银行卡</view>
				</view>
				<view class="list_fr">{{yxUserBank.length == 0 ? '未设置' : '已绑定'}}</view>
			</view>
			<view class="list" @click="getPayCard(2)">
				<view class="list_fl">
					<image class="paycard" src="https://taobaoke-paimai.oss-cn-beijing.aliyuncs.com/wxpay.png" mode=""></image>
					<view class="carddsc">绑定微信</view>
				</view>
				<view class="list_fr">{{(userInfo.weixinAccount == '' || userInfo.weixinAccount == null)? '未设置' : '已绑定'}}</view>
			</view>
			<view class="list" @click="getPayCard(3)">
				<view class="list_fl">
					<image class="paycard" src="https://taobaoke-paimai.oss-cn-beijing.aliyuncs.com/alipay.png" mode=""></image>
					<view class="carddsc">绑定支付宝</view>
				</view>
				<view class="list_fr">{{(userInfo.zhifubaoAccount == null || userInfo.zhifubaoAccount == '') ? '未设置' : '已绑定'}}</view>
			</view>
			<!-- <view class="list" @click="getPayCard(4)">
				<view class="list_fl">
					<image class="paycard" src="https://taobaoke-paimai.oss-cn-beijing.aliyuncs.com/setpwd.png" mode=""></image>
					<view class="carddsc">支付密码</view>
				</view>
				<view class="list_fr">{{users.isFirst == 0 ? '未设置' : '已设置'}}</view>
			</view> -->
		</view>
	</view>
</template>

<script>
	import api from "../../../../common/api/api.js"
	export default {
		data() {
			return {
				users:{},
				userInfo:{},
				yxUserBank:[]
			}
		},
		onLoad() {
			let that = this;
			uni.$on('login',function(data){
				// that.cacheHelper.isLogin()
				// that.cacheHelper.updateUserInfo()
				that.getUserInfo()
			})
			that.getUserInfo()
		},
		onUnload() {
			uni.$off('login');
		},
		methods: {
			// 绑定
			getPayCard: function (type) {
				let users = this.users;
				if (type == 1) {
					if (this.yxUserBank.length == 0) {
						uni.navigateTo({
							url: 'bindingBank/bindingBank',
						});
					} else {
						uni.navigateTo({
							url: 'changeBank/changeBank',
						});
					}
				} else if (type == 2) {
					if (users.yxUserinfo.bindWx == 0) {
						uni.navigateTo({
							url: 'bindingWxpay/bindingWxpay',
						});
					} else {
						uni.navigateTo({
							url: 'changeWxpay/changeWxpay',
						});
					}
				} else if (type == 3) { // 支付宝
					if (users.yxUserinfo.bindZfb == 0) {
						uni.navigateTo({
							url: 'bindingAlipay/bindingAlipay',
						});
					} else if (users.yxUserinfo.zhifubaoAccount != ''){
						uni.navigateTo({
							url: 'changeAlipay/changeAlipay',
						});
					}
				} else if (type == 4) {
					if (users.isFirst == 0) {
						uni.navigateTo({
							url: 'setPayPassword/setPayPassword',
						});
					} else if (users.isFirst == 1){
						uni.navigateTo({
							url: 'bindPassword/bindPassword',
						});
					}
				}
			},
			// 获取我的信息
			getUserInfo: function () {
				api.getUserInfo().then(res => {
					console.log(res)
					this.users = res.data;
					this.userInfo = res.data.yxUserinfo;
					this.yxUserBank = res.data.yxUserBank
				})
			}
		}
	}
</script>

<style lang="less">
	page {
		width: 100%;
		box-sizing: border-box;
		letter-spacing: 3rpx;
		background: #F5F5F5;
		font-size: 30rpx;
		color: #140005;
		padding: 20rpx 0;
	}
	.content {
		width: 100%;
		box-sizing: border-box;
	}
	.group {
		width: 100%;
		box-sizing: border-box;
		background: #FFFFFF;
		.list {
			width: 100%;
			box-sizing: border-box;
			padding: 28rpx 30rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;
			border-bottom: 2rpx solid #F5F5F5;
			.list_fl {
				width: 300rpx;
				box-sizing: border-box;
				display: flex;
				justify-content: flex-start;
				align-items: center;
				.paycard {
					width: 54rpx;
					height: 54rpx;
				}
				.carddsc {
					padding-left: 10rpx;
				}
				
			}
			.list_fr {
				width: calc(100% - 300rpx);
				box-sizing: border-box;
				text-align: right;
				font-size: 28rpx;
				color: #666666;
			}
		}
		
	}

</style>
